package com.kye.express.business.invoice_online.detail;

import android.content.Context;
import android.content.Intent;
import android.databinding.DataBindingUtil;
import android.os.Bundle;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.widget.Toolbar;
import com.kye.express.R;
import com.kye.express.business.base.BaseToolbarActivity;
import com.kye.express.databinding.ActivityBaseFragmentContainsBinding;
import com.kye.model.bean.invoice_online.GetInvoiceDetailResultBean;

import java.util.List;

/**
 * 发票详情
 */
public class InvoiceDetailActivity extends BaseToolbarActivity implements InvoiceDetailListener {
    private static final String ARG_DATA = "data";
    private ActivityBaseFragmentContainsBinding mBinding;
    private String mGroupCode = "";

    public static void startActivity(Context context,String groupCode) {
        Intent intent = new Intent(context, InvoiceDetailActivity.class);
        intent.putExtra(ARG_DATA,groupCode);
        context.startActivity(intent);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mBinding = DataBindingUtil.setContentView(this, R.layout.activity_base_fragment_contains);
        setUpToolbar((Toolbar) findViewById(R.id.toolbar));
        mGroupCode = getIntent().getStringExtra(ARG_DATA);
        FragmentTransaction transaction = getSupportFragmentManager()
                .beginTransaction();
        transaction.replace(R.id.contains, InvoiceDetailFragment.newInstance(mGroupCode)).commit();
        transaction.addToBackStack(null);
    }

    @Override
    public void onOpenInvoice(GetInvoiceDetailResultBean.SourceCodeDataBean sourceCodeDataBean) {
        FragmentTransaction transaction = getSupportFragmentManager()
                .beginTransaction();
        transaction.replace(R.id.contains, ElectronicInvoiceFragment.newInstance(sourceCodeDataBean)).commit();
        transaction.addToBackStack(null);
    }

    @Override
    public void onOpenWaybillList(List<GetInvoiceDetailResultBean.WaybillNoDataBean> waybillNoDataBeans) {
        FragmentTransaction transaction = getSupportFragmentManager()
                .beginTransaction();
        transaction.replace(R.id.contains, WaybillListFragment.newInstance(waybillNoDataBeans)).commit();
        transaction.addToBackStack(null);
    }
}
